﻿// Study0503.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
// 第五章 数据的共享与保护 友元


#include <iostream>
using namespace std;

class Point
{
public:
    Point(int xx = 0, int yy = 0) :x(xx), y(yy) {}
    int GetX() {
        return x;
    }
    int GexY()
    {
        return y;
    }
    friend float dist(Point& a, Point& b);
private:
    int x, y;
};

float dist(Point& a, Point& b)
{
    float x = a.x - b.x;
    float y = a.y - b.y;
    return static_cast<float>(sqrt(x * x + y * y));
}

int main()
{
    Point p1(1, 1), p2(4, 5);
    cout << "The distance is :";
    cout << dist(p1, p2) << endl;
    return 0;
}


